#pragma once
#include <strsafe.h>
#include <Shlwapi.h>
#include <tchar.h>

#define UNICODE
#define _UNICODE

class Char_String
{
public:

	static int AnsiToUnicode(LPSTR input, LPWSTR output)
	{
		int ansiLen = strlen(input);
		int uniLen = MultiByteToWideChar(0, 0, input, -1, NULL, 0);
		output = (LPWSTR)malloc(uniLen * sizeof(wchar_t));
		int uniLen2 = MultiByteToWideChar(0, 0, input, ansiLen, output, uniLen);
		return uniLen2;
	}

	static int UnicodeToAnsi(LPWSTR input, LPSTR output)
	{
		int l0 = strlen(output);
		int l1 = wcslen(input);
		int uniLen = _tcslen(input);
		int ansiLen = WideCharToMultiByte(0, 0, input, -1, NULL, 0, NULL, NULL);
		output = (LPSTR)malloc(ansiLen * sizeof(CHAR));

		CHAR defaultChar = '$';
		BOOL useDefaultChar = true;
		LPCCH pDefaultChar = &defaultChar;
		LPBOOL pUseDefaultChar = &useDefaultChar;

		int ansiLen2 = WideCharToMultiByte(0, 0, input, uniLen, output, ansiLen, pDefaultChar, pUseDefaultChar);
		return ansiLen2;
	}

	static int CompareStr(LPWSTR str1, LPWSTR str2) 
	{
		LCID lcid = GetThreadLocale();
		DWORD dwCodflags = NORM_IGNORECASE;
		int res1 = CompareString(lcid, dwCodflags, str1, _tcslen(str1), str2, _tcslen(str2));

		int res2 = CompareStringOrdinal(str1, _tcslen(str1), str2, _tcslen(str2), TRUE);

		//int res3 = strcmp(str1, str2);
		 
		return res2;
	}
};



